/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package futco.patrones.syscand.jsf.framework.util;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 *
 * @author casewaredes03
 */
public class Mensajes {

    private static Mensajes INSTANCIA = null;

    private Mensajes() {
    }

    private synchronized static void crearInstancia() {
        if (INSTANCIA == null) {
            INSTANCIA = new Mensajes();
        }
    }

    public static Mensajes getInstancia() {
        if (INSTANCIA == null) {
            crearInstancia();
        }
        return INSTANCIA;
    }

    public static void mensajeInformacion(Object summary, Object detail) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, summary.toString(), detail.toString()));
    }

    public static void mensajeError(Object summary, Object detail) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, summary.toString(), detail.toString()));
    }

    public static void mensajeFatal(Object summary, Object detail) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, summary.toString(), detail.toString()));
    }

    public static void mensajePrecaucion(Object summary, Object detail) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, summary.toString(), detail.toString()));
    }
}
